﻿/*
 
Celerity: Sensory Overload
Copright 2012 by Adam Hill, David Gannon, Thomas Tamblyn & Patrick Ytting
Contact: adam.hill@outlook.com
Website: adamhill.org
Licence: MS-Pl Licence
  
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Celerity.World
{
	class CollisionRect
	{
		// 0 -- 1 - -- +
		// |    | |
		// 2 -- 3 +
		public Vector2[] points;
		public bool zUnset = true;
		public int boxPositionIndex;

		//angle and z are the centre point
		public CollisionRect(float tunnelCellSize, float tunnelNumSegments, float angle, float z, int boxPositionIndex)
		{
			float rads = (float)(2 * Math.PI);
			float widthOver2 = (float)Math.PI / tunnelNumSegments;
			float heightOver2 = tunnelCellSize / 2;
			this.boxPositionIndex = boxPositionIndex;
			points = new Vector2[4] { new Vector2(rads - angle - widthOver2, z - heightOver2), new Vector2(rads - angle + widthOver2, z - heightOver2), 
									  new Vector2(rads - angle - widthOver2, z + heightOver2), new Vector2(rads - angle + widthOver2, z + heightOver2) };
		}

		public void SetZ(float z)
		{
			for(int i = 0; i < 4; i++)
			{
				points[i].Y += z;
			}
			this.zUnset = false;
		}

		public void Update(float deltaPhase)
		{
			for (int i = 0; i < 4; i++)
			{
				points[i].Y += deltaPhase;
			}
		}
	}
}
